#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define int long long
using namespace std;
int a[200003],b[200003];
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    scanf("%lld",&t);
    while(t--){
        memset(b,0,sizeof(b));
        int n;
        scanf("%lld",&n);
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
        int ans=0;
        while(b[0]==0){
            int sum=0;
            for(int i=1;i<=n;i++){
                for(int j=i-1;j>0;j--)
                    if(b[i]==b[j]){
                        if(a[i]==a[j]){
                            sum+=a[i];
                        }
                        break;
                    }

            }
            ans=max(ans,sum);
            b[n]++;
            int j=n;
            while(b[j]>1){
                b[j]=0;
                j--;
                b[j]++;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}/*15
5 3 7 2 4 13 11 6 5 5 3 5 12 8 13
15
1 12 11 11 7 11 15 6 4 6 3 15 7 5 2*/
